Public Class WorkingWithEmulatorsForm

    Public Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()

        ' To use a GPS device emulator, we simply point NmeaInterpreter classes
        ' to the emulator classes.  GPS.NET emulators behave as Stream objects,
        ' allowing them to easily replace actual streams from hardware such as serial
        ' ports or Bluetooth.

        EarthmateInterpreter.BaseStream = _
          New GeoFramework.Gps.Emulators.DeLormeEarthmateUsbEmulator

        eTrexInterpreter.BaseStream = _
         New GeoFramework.Gps.Emulators.GarminEtrexVistaNmeaEmulator

        ' Start both of the interpreters
        EarthmateInterpreter.Start()
        eTrexInterpreter.Start()

    End Sub

    Private Sub EarthmateInterpreter_SentenceReceived(ByVal sender As Object, ByVal e As GeoFramework.Gps.Nmea.NmeaSentenceEventArgs) Handles EarthmateInterpreter.SentenceReceived
        ' Add the emulated sentence to the list box
        EarthmateSentencesListBox.Items.Add(e.Sentence.ToString())

        ' Make sure the last item is always visible
        EarthmateSentencesListBox.SelectedIndex = EarthmateSentencesListBox.Items.Count - 1
    End Sub

    Private Sub eTrexInterpreter_SentenceReceived(ByVal sender As Object, ByVal e As GeoFramework.Gps.Nmea.NmeaSentenceEventArgs) Handles eTrexInterpreter.SentenceReceived
        ' Add the emulated sentence to the list box
        eTrexSentencesListBox.Items.Add(e.Sentence.ToString())

        ' Make sure the last item is always visible
        eTrexSentencesListBox.SelectedIndex = eTrexSentencesListBox.Items.Count - 1
    End Sub

End Class